Skip to content

Return MethodNotFound (-32601) for unrecognized LSP requests#4040

Merged
vinistock merged 3 commits intoShopify:mainfrom
IgorFroehner:fix-method-not-found-error
Apr 8, 2026
Merged

Return MethodNotFound (-32601) for unrecognized LSP requests#4040
vinistock merged 3 commits intoShopify:mainfrom
IgorFroehner:fix-method-not-found-error

Conversation

@IgorFroehner
Copy link
Copy Markdown
Contributor

@IgorFroehner IgorFroehner commented Mar 31, 2026

Motivation

Fixes #3981

The process_message case statement had no else clause, so requests for unsupported methods were silently dropped. This caused clients to hang indefinitely waiting for a response. The LSP spec requires servers to respond with error code -32601 for unsupported methods.

Implementation

Just answer with Method not found when the message method don't match any of the switch statement branches.

Automated Tests

I added one check to see if the message RubyLsp::Error was sent.

Manual Tests

Start the server via bundle exec ruby-lsp and send a request with an unsupported method (e.g. textDocument/nonExistentMethod). Verify the server responds with {"error": {"code": -32601, "message": "Method not found: textDocument/nonExistentMethod"}} instead of silently dropping the request.

The process_message case statement had no else clause, so requests for
unsupported methods were silently dropped. This caused clients to hang
indefinitely waiting for a response. The LSP spec requires servers to
respond with error code -32601 for unsupported methods.

Fixes Shopify#3981
@IgorFroehner IgorFroehner requested a review from a team as a code owner March 31, 2026 02:46
@IgorFroehner
Copy link
Copy Markdown
Contributor Author

I have signed the CLA!

@vinistock vinistock added bugfix This PR will fix an existing bug server This pull request should be included in the server gem's release notes labels Mar 31, 2026
@IgorFroehner IgorFroehner requested a review from vinistock March 31, 2026 19:28
@IgorFroehner
Copy link
Copy Markdown
Contributor Author

@vinistock can I get another review here?

Copy link
Copy Markdown
Member

@vinistock vinistock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution!

@vinistock
Copy link
Copy Markdown
Member

There are some type checking errors. We probably just need the RubyLsp:: prefix before Constant since the tests don't re-open the RubyLsp module.

@vinistock vinistock merged commit 360d554 into Shopify:main Apr 8, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix This PR will fix an existing bug server This pull request should be included in the server gem's release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unrecognized LSP requests are silently dropped instead of returning MethodNotFound (-32601)

2 participants